package com.syt.suan.common.mybatis.config;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class MetaObjectHandler implements com.baomidou.mybatisplus.core.handlers.MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        LocalDateTime now = LocalDateTime.now();
        this.strictInsertFill(metaObject,
                "createTime",
                LocalDateTime.class, now
        );
        this.strictInsertFill(metaObject,
                "updateTime",
                LocalDateTime.class, now
        );
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        LocalDateTime now = LocalDateTime.now();
        this.strictInsertFill(metaObject,
                "updateTime",
                LocalDateTime.class, now
        );
    }
}
